<?php
class MyView {
	protected $template_dir = "templates/";
	protected $vars = array();
	
	public function __construct($template_dir = NULL){
		if($template_dir !== NULL){
			$this->template_dir = $template_dir;
		}
	}
	
	public function render($template_file){
		if(file_exists($this->template_dir.$template_file)){
			include $this->template_dir.$template_file;
		} else {
			throw new Exception("no template file".$template_file." present in directory".$this->template_dir);
		}
	}
	
	public function __set($name, $value){
		$this->vars[$name] = $value;
	}
	
	public function __get($name){
		return $this->vars[$name];
	}
}
?>